<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JSX</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      #header{
        height: 100px;
        background-color: #aef;
      }
      #main{
        height: 400px;
        background-color: rgb(255, 239, 170);
      }
      #footer{
        height: 100px;
        background-color: rgb(226, 153, 204);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //类式组件
      class Header extends React.Component{
        //类式组件中一定要包含 render 方法
        render(){
          return <div id="header">头部区域</div>;
        }
      }

      //主体结构的组件
      class Content extends React.Component{
        render(){
          return <div id="main">主体区域</div>;
        }
      }

      //底部结构
      class Footer extends React.Component{
        render(){
          return <div id="footer">底部区域</div>;
        }
      }

      //完整结构的组件
      class App extends React.Component{
        render(){
          //创建虚拟 DOM 对象 
          //对于类式组件, 渲染的时候, 会查找同类的类, 实例化对象, 然后使用实例化对象调用 render 方法, 获得虚拟 DOM 对象
          let vdom = <div>
              <Header />
              <Content />
              <Footer />
            </div>;
          //返回虚拟 DOM
          return vdom;
        }
      }

      //渲染
      ReactDOM.render(<App />, document.querySelector('#root'))
    </script>
  </body>
</html>
